import { InitMiddleware } from './middleware/init.middleware';
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AdminModule } from './module/admin/admin.module';
import { DefaultModule } from './module/default/default.module';
import { ApiModule } from './module/api/api.module';
import { ToolsService } from './service/tools/tools.service';
import { MongooseModule } from '@nestjs/mongoose';
import { CommonModule } from './module/common/common.module';
import { HttpModule } from '@nestjs/axios';
import config from 'src/config/config';
@Module({
    imports: [
        AdminModule,
        DefaultModule,
        ApiModule,
        MongooseModule.forRoot('mongodb://localhost:27017/nestxiaomi'),
        CommonModule,
        HttpModule.register(config.httpModuleOptions),
    ],
    controllers: [AppController],
    providers: [AppService, ToolsService],
})
export class AppModule implements NestModule {
    configure(consumer: MiddlewareConsumer) {
        consumer.apply(InitMiddleware).forRoutes('*');
    }
}
